/**
 * @author zhoutao
*  2010-5-11
 */
package com.jlt.entity.dic;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.jlt.entity.BaseEntity;


/**
 * 职位
 * @author zhoutao
 *
 */
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "dic_entity")
//默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DicEntity  extends BaseEntity{
	@Column(nullable = false)
	private String name;//字典实体名称
	@Column(nullable = false)
	private String code ;//字典实体代码 
	@Column(nullable = false)
	private String status;//字典实体状态
	private String description;//备注
	
	private DicType dicType;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	// 多对一定义
	@ManyToOne
	// 中间表定义,表名采用默认命名规则
	@JoinColumn(name="dic_type_id") 
	// Fecth策略定义
	//@Fetch(FetchMode.SUBSELECT)
	// 集合按id排序.
	@OrderBy("id")
	// 集合中对象id的缓存.
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public DicType getDicType() {
		return dicType;
	}
	public void setDicType(DicType dicType) {
		this.dicType = dicType;
	}
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
